//+------------------------------------------------------------------+
//|                                                     Mn VLine.mq4 |
//+------------------------------------------------------------------+
#property copyright "Mn"
#property link      ""
#property strict;
#property indicator_chart_window

extern int                 YTime = 1;
extern int               History = 5000;     //History
extern color              Yearly = Goldenrod;//Line
extern ENUM_LINE_STYLE LineStyle = 0;        //Line style
extern int             LineWidth = 2;        //Line width
extern bool       LineBackground = true;     //Show line as background
extern bool             ShowLine = true;     //Show line
//+------------------------------------------------------------------+
int init()
  {
   return(0);
  }
//+------------------------------------------------------------------+
int deinit()
  {
   ObjectsDeleteAll(0,"VL");//Delete V Lines
   return(0);
  }
//+------------------------------------------------------------------+
int start()
  {
   double mm=WindowPriceMin()+5*Point*10;
   for(int i=0; i<History; i++)
     {
      if(TimeYear(Time[i])==0 && TimeYear(Time[i])==YTime)
        {
         ObjectCreate("VL"+(string)i,OBJ_VLINE,0,0,0,0,0);
         ObjectSet("VL"+(string)i,OBJPROP_TIME1,Time[i]);
         ObjectSet("VL"+(string)i,OBJPROP_COLOR,Yearly);
         ObjectSet("VL"+(string)i,OBJPROP_STYLE,LineStyle);
         ObjectSet("VL"+(string)i,OBJPROP_WIDTH,LineWidth);
         ObjectSet("VL"+(string)i,OBJPROP_BACK,LineBackground);
        }

      if(ShowLine)
        {
         if(TimeYear(Time[i])!=TimeYear(Time[i+1]))
           {
            ObjectDelete("VL"+(string)i);
            ObjectCreate("VL"+(string)i,OBJ_VLINE,0,0,0,0,0);
            ObjectSet("VL"+(string)i,OBJPROP_TIME1,Time[i]);
            ObjectSet("VL"+(string)i,OBJPROP_COLOR,Yearly);
            ObjectSet("VL"+(string)i,OBJPROP_STYLE,LineStyle);
            ObjectSet("VL"+(string)i,OBJPROP_WIDTH,LineWidth);
            ObjectSet("VL"+(string)i,OBJPROP_BACK,LineBackground);
           }
         if(TimeYear(Time[i])==1 && TimeYear(Time[i+1])!=1)
           {
            ObjectDelete("VL"+(string)i);
            ObjectCreate("VL"+(string)i,OBJ_VLINE,0,0,0,0,0);
            ObjectSet("VL"+(string)i,OBJPROP_TIME1,Time[i]);
            ObjectSet("VL"+(string)i,OBJPROP_COLOR,Yearly);
            ObjectSet("VL"+(string)i,OBJPROP_STYLE,LineStyle);
            ObjectSet("VL"+(string)i,OBJPROP_WIDTH,LineWidth);
            ObjectSet("VL"+(string)i,OBJPROP_BACK,LineBackground);
           }
        }
     }
   return(0);
  }
//+------------------------------------------------------------------+
